package com.firmail.enumeration.impl;

import lombok.Getter;

@Getter
public enum CodeEnum {

    SUCCESS(10000, "操作成功"),
    FAILURE(10001, "操作失败");


    private int code;
    private String msg;

    //为了更好的返回代号和说明，必须呀重写构造方法
    private CodeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 根据value返回枚举类型,主要在switch中使用
     */
    public static CodeEnum getByValue(int value) {
        for (CodeEnum code : values()) {
            if (code.getCode() == value) {
                return code;

            }
        }
        return null;
    }


}
